home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / sun / print / Win32PrintJob.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  13.1 KB  |  658 lines

  1. package sun.print;
  2.  
  3. import java.awt.print.PageFormat;
  4. import java.awt.print.Pageable;
  5. import java.awt.print.Paper;
  6. import java.awt.print.Printable;
  7. import java.awt.print.PrinterException;
  8. import java.awt.print.PrinterJob;
  9. import java.io.BufferedInputStream;
  10. import java.io.File;
  11. import java.io.FileNotFoundException;
  12. import java.io.FileOutputStream;
  13. import java.io.IOException;
  14. import java.io.InputStream;
  15. import java.io.Reader;
  16. import java.net.URI;
  17. import java.util.Locale;
  18. import java.util.Vector;
  19. import javax.print.CancelablePrintJob;
  20. import javax.print.Doc;
  21. import javax.print.DocFlavor;
  22. import javax.print.PrintException;
  23. import javax.print.PrintService;
  24. import javax.print.DocFlavor.BYTE_ARRAY;
  25. import javax.print.DocFlavor.INPUT_STREAM;
  26. import javax.print.DocFlavor.URL;
  27. import javax.print.attribute.Attribute;
  28. import javax.print.attribute.AttributeSet;
  29. import javax.print.attribute.AttributeSetUtilities;
  30. import javax.print.attribute.DocAttributeSet;
  31. import javax.print.attribute.HashPrintJobAttributeSet;
  32. import javax.print.attribute.HashPrintRequestAttributeSet;
  33. import javax.print.attribute.PrintJobAttribute;
  34. import javax.print.attribute.PrintJobAttributeSet;
  35. import javax.print.attribute.PrintRequestAttribute;
  36. import javax.print.attribute.PrintRequestAttributeSet;
  37. import javax.print.attribute.standard.Copies;
  38. import javax.print.attribute.standard.Destination;
  39. import javax.print.attribute.standard.DocumentName;
  40. import javax.print.attribute.standard.Fidelity;
  41. import javax.print.attribute.standard.JobName;
  42. import javax.print.attribute.standard.JobOriginatingUserName;
  43. import javax.print.attribute.standard.Media;
  44. import javax.print.attribute.standard.MediaSize;
  45. import javax.print.attribute.standard.MediaSizeName;
  46. import javax.print.attribute.standard.OrientationRequested;
  47. import javax.print.attribute.standard.PrinterIsAcceptingJobs;
  48. import javax.print.attribute.standard.PrinterState;
  49. import javax.print.attribute.standard.PrinterStateReason;
  50. import javax.print.attribute.standard.PrinterStateReasons;
  51. import javax.print.attribute.standard.RequestingUserName;
  52. import javax.print.event.PrintJobAttributeListener;
  53. import javax.print.event.PrintJobEvent;
  54. import javax.print.event.PrintJobListener;
  55. import sun.awt.windows.WPrinterJob;
  56.  
  57. public class Win32PrintJob implements CancelablePrintJob {
  58.    private transient Vector jobListeners;
  59.    private transient Vector attrListeners;
  60.    private transient Vector listenedAttributeSets;
  61.    private Win32PrintService service;
  62.    private boolean fidelity;
  63.    private boolean printing = false;
  64.    private boolean printReturned = false;
  65.    private PrintRequestAttributeSet reqAttrSet = null;
  66.    private PrintJobAttributeSet jobAttrSet = null;
  67.    private PrinterJob job;
  68.    private Doc doc;
  69.    private String mDestination = null;
  70.    private InputStream instream = null;
  71.    private Reader reader = null;
  72.    private String jobName = "Java Printing";
  73.    private int copies = 0;
  74.    private MediaSizeName mediaName = null;
  75.    private MediaSize mediaSize = null;
  76.    private OrientationRequested orient = null;
  77.    private long hPrintJob;
  78.    private static final int PRINTBUFFERLEN = 8192;
  79.  
  80.    Win32PrintJob(Win32PrintService var1) {
  81.       this.service = var1;
  82.    }
  83.  
  84.    public PrintService getPrintService() {
  85.       return this.service;
  86.    }
  87.  
  88.    public PrintJobAttributeSet getAttributes() {
  89.       synchronized(this) {
  90.          if (this.jobAttrSet == null) {
  91.             HashPrintJobAttributeSet var2 = new HashPrintJobAttributeSet();
  92.             return AttributeSetUtilities.unmodifiableView(var2);
  93.          } else {
  94.             return this.jobAttrSet;
  95.          }
  96.       }
  97.    }
  98.  
  99.    public void addPrintJobListener(PrintJobListener var1) {
  100.       synchronized(this) {
  101.          if (var1 != null) {
  102.             if (this.jobListeners == null) {
  103.                this.jobListeners = new Vector();
  104.             }
  105.  
  106.             this.jobListeners.add(var1);
  107.          }
  108.       }
  109.    }
  110.  
  111.    public void removePrintJobListener(PrintJobListener var1) {
  112.       synchronized(this) {
  113.          if (var1 != null && this.jobListeners != null) {
  114.             this.jobListeners.remove(var1);
  115.             if (this.jobListeners.isEmpty()) {
  116.                this.jobListeners = null;
  117.             }
  118.  
  119.          }
  120.       }
  121.    }
  122.  
  123.    private void closeDataStreams() {
  124.       if (this.doc != null) {
  125.          Object var1 = null;
  126.  
  127.          try {
  128.             var1 = this.doc.getPrintData();
  129.          } catch (IOException var25) {
  130.             return;
  131.          }
  132.  
  133.          if (this.instream != null) {
  134.             try {
  135.                this.instream.close();
  136.             } catch (IOException var23) {
  137.             } finally {
  138.                this.instream = null;
  139.             }
  140.          } else if (this.reader != null) {
  141.             try {
  142.                this.reader.close();
  143.             } catch (IOException var21) {
  144.             } finally {
  145.                this.reader = null;
  146.             }
  147.          } else if (var1 instanceof InputStream) {
  148.             try {
  149.                ((InputStream)var1).close();
  150.             } catch (IOException var20) {
  151.             }
  152.          } else if (var1 instanceof Reader) {
  153.             try {
  154.                ((Reader)var1).close();
  155.             } catch (IOException var19) {
  156.             }
  157.          }
  158.  
  159.       }
  160.    }
  161.  
  162.    private void notifyEvent(int var1) {
  163.       switch (var1) {
  164.          case 101:
  165.          case 102:
  166.          case 103:
  167.          case 105:
  168.          case 106:
  169.             this.closeDataStreams();
  170.          case 104:
  171.          default:
  172.             synchronized(this) {
  173.                if (this.jobListeners != null) {
  174.                   PrintJobEvent var4 = new PrintJobEvent(this, var1);
  175.  
  176.                   for(int var5 = 0; var5 < this.jobListeners.size(); ++var5) {
  177.                      PrintJobListener var3 = (PrintJobListener)this.jobListeners.elementAt(var5);
  178.                      switch (var1) {
  179.                         case 101:
  180.                            var3.printJobCanceled(var4);
  181.                            break;
  182.                         case 102:
  183.                            var3.printJobCompleted(var4);
  184.                            break;
  185.                         case 103:
  186.                            var3.printJobFailed(var4);
  187.                         case 104:
  188.                         default:
  189.                            break;
  190.                         case 105:
  191.                            var3.printJobNoMoreEvents(var4);
  192.                            break;
  193.                         case 106:
  194.                            var3.printDataTransferCompleted(var4);
  195.                      }
  196.                   }
  197.                }
  198.  
  199.             }
  200.       }
  201.    }
  202.  
  203.    public void addPrintJobAttributeListener(PrintJobAttributeListener var1, PrintJobAttributeSet var2) {
  204.       synchronized(this) {
  205.          if (var1 != null) {
  206.             if (this.attrListeners == null) {
  207.                this.attrListeners = new Vector();
  208.                this.listenedAttributeSets = new Vector();
  209.             }
  210.  
  211.             this.attrListeners.add(var1);
  212.             if (var2 == null) {
  213.                var2 = new HashPrintJobAttributeSet();
  214.             }
  215.  
  216.             this.listenedAttributeSets.add(var2);
  217.          }
  218.       }
  219.    }
  220.  
  221.    public void removePrintJobAttributeListener(PrintJobAttributeListener var1) {
  222.       synchronized(this) {
  223.          if (var1 != null && this.attrListeners != null) {
  224.             int var3 = this.attrListeners.indexOf(var1);
  225.             if (var3 != -1) {
  226.                this.attrListeners.remove(var3);
  227.                this.listenedAttributeSets.remove(var3);
  228.                if (this.attrListeners.isEmpty()) {
  229.                   this.attrListeners = null;
  230.                   this.listenedAttributeSets = null;
  231.                }
  232.  
  233.             }
  234.          }
  235.       }
  236.    }
  237.  
  238.    public void print(Doc var1, PrintRequestAttributeSet var2) throws PrintException {
  239.       synchronized(this) {
  240.          if (this.printing) {
  241.             throw new PrintException("already printing");
  242.          }
  243.  
  244.          this.printing = true;
  245.       }
  246.  
  247.       PrinterState var3 = (PrinterState)this.service.getAttribute(PrinterState.class);
  248.       if (var3 == PrinterState.STOPPED) {
  249.          PrinterStateReasons var4 = (PrinterStateReasons)this.service.getAttribute(PrinterStateReasons.class);
  250.          if (var4 != null && var4.containsKey(PrinterStateReason.SHUTDOWN)) {
  251.             throw new PrintException("PrintService is no longer available.");
  252.          }
  253.       }
  254.  
  255.       if ((PrinterIsAcceptingJobs)this.service.getAttribute(PrinterIsAcceptingJobs.class) == PrinterIsAcceptingJobs.NOT_ACCEPTING_JOBS) {
  256.          throw new PrintException("Printer is not accepting job.");
  257.       } else {
  258.          this.doc = var1;
  259.          DocFlavor var41 = var1.getDocFlavor();
  260.  
  261.          Object var5;
  262.          try {
  263.             var5 = var1.getPrintData();
  264.          } catch (IOException var35) {
  265.             this.notifyEvent(103);
  266.             throw new PrintException("can't get print data: " + var35.toString());
  267.          }
  268.  
  269.          if (var41 != null && this.service.isDocFlavorSupported(var41)) {
  270.             this.initializeAttributeSets(var1, var2);
  271.             this.getAttributeValues(var41);
  272.             String var6 = var41.getRepresentationClassName();
  273.             if (!var41.equals(INPUT_STREAM.GIF) && !var41.equals(INPUT_STREAM.JPEG) && !var41.equals(INPUT_STREAM.PNG) && !var41.equals(BYTE_ARRAY.GIF) && !var41.equals(BYTE_ARRAY.JPEG) && !var41.equals(BYTE_ARRAY.PNG)) {
  274.                if (!var41.equals(URL.GIF) && !var41.equals(URL.JPEG) && !var41.equals(URL.PNG)) {
  275.                   if (var6.equals("java.awt.print.Pageable")) {
  276.                      try {
  277.                         this.pageableJob((Pageable)var1.getPrintData());
  278.                         this.service.wakeNotifier();
  279.                      } catch (ClassCastException var26) {
  280.                         this.notifyEvent(103);
  281.                         throw new PrintException(var26);
  282.                      } catch (IOException var27) {
  283.                         this.notifyEvent(103);
  284.                         throw new PrintException(var27);
  285.                      }
  286.                   } else if (var6.equals("java.awt.print.Printable")) {
  287.                      try {
  288.                         this.printableJob((Printable)var1.getPrintData());
  289.                         this.service.wakeNotifier();
  290.                      } catch (ClassCastException var28) {
  291.                         this.notifyEvent(103);
  292.                         throw new PrintException(var28);
  293.                      } catch (IOException var29) {
  294.                         this.notifyEvent(103);
  295.                         throw new PrintException(var29);
  296.                      }
  297.                   } else if (!var6.equals("[B") && !var6.equals("java.io.InputStream") && !var6.equals("java.net.URL")) {
  298.                      this.notifyEvent(103);
  299.                      throw new PrintException("unrecognized class: " + var6);
  300.                   } else {
  301.                      if (var6.equals("java.net.URL")) {
  302.                         java.net.URL var7 = (java.net.URL)var5;
  303.  
  304.                         try {
  305.                            this.instream = var7.openStream();
  306.                         } catch (IOException var31) {
  307.                            this.notifyEvent(103);
  308.                            throw new PrintException(var31.toString());
  309.                         }
  310.                      } else {
  311.                         try {
  312.                            this.instream = var1.getStreamForBytes();
  313.                         } catch (IOException var30) {
  314.                            this.notifyEvent(103);
  315.                            throw new PrintException(var30.toString());
  316.                         }
  317.                      }
  318.  
  319.                      if (this.instream == null) {
  320.                         this.notifyEvent(103);
  321.                         throw new PrintException("No stream for data");
  322.                      } else if (this.mDestination != null) {
  323.                         try {
  324.                            FileOutputStream var43 = new FileOutputStream(this.mDestination);
  325.                            byte[] var45 = new byte[1024];
  326.  
  327.                            int var46;
  328.                            while((var46 = this.instream.read(var45, 0, var45.length)) >= 0) {
  329.                               var43.write(var45, 0, var46);
  330.                            }
  331.  
  332.                            var43.flush();
  333.                            var43.close();
  334.                         } catch (FileNotFoundException var36) {
  335.                            this.notifyEvent(103);
  336.                            throw new PrintException(var36.toString());
  337.                         } catch (IOException var37) {
  338.                            this.notifyEvent(103);
  339.                            throw new PrintException(var37.toString());
  340.                         }
  341.  
  342.                         this.notifyEvent(106);
  343.                         this.notifyEvent(102);
  344.                         this.service.wakeNotifier();
  345.                      } else if (!this.startPrintRawData(this.service.getName(), this.jobName)) {
  346.                         this.notifyEvent(103);
  347.                         throw new PrintException("Print job failed to start.");
  348.                      } else {
  349.                         BufferedInputStream var42 = new BufferedInputStream(this.instream);
  350.                         int var8 = 0;
  351.  
  352.                         try {
  353.                            byte[] var9 = new byte[8192];
  354.  
  355.                            while((var8 = var42.read(var9, 0, 8192)) >= 0) {
  356.                               if (!this.printRawData(var9, var8)) {
  357.                                  var42.close();
  358.                                  this.notifyEvent(103);
  359.                                  throw new PrintException("Problem while spooling data");
  360.                               }
  361.                            }
  362.  
  363.                            var42.close();
  364.                            if (!this.endPrintRawData()) {
  365.                               this.notifyEvent(103);
  366.                               throw new PrintException("Print job failed to close properly.");
  367.                            }
  368.  
  369.                            this.notifyEvent(106);
  370.                         } catch (IOException var38) {
  371.                            this.notifyEvent(103);
  372.                            throw new PrintException(var38.toString());
  373.                         } finally {
  374.                            this.notifyEvent(105);
  375.                         }
  376.  
  377.                         this.service.wakeNotifier();
  378.                      }
  379.                   }
  380.                } else {
  381.                   try {
  382.                      this.printableJob(new ImagePrinter((java.net.URL)var5));
  383.                      this.service.wakeNotifier();
  384.                   } catch (ClassCastException var32) {
  385.                      this.notifyEvent(103);
  386.                      throw new PrintException(var32);
  387.                   }
  388.                }
  389.             } else {
  390.                try {
  391.                   this.instream = var1.getStreamForBytes();
  392.                   if (this.instream == null) {
  393.                      this.notifyEvent(103);
  394.                      throw new PrintException("No stream for data");
  395.                   } else {
  396.                      this.printableJob(new ImagePrinter(this.instream));
  397.                      this.service.wakeNotifier();
  398.                   }
  399.                } catch (ClassCastException var33) {
  400.                   this.notifyEvent(103);
  401.                   throw new PrintException(var33);
  402.                } catch (IOException var34) {
  403.                   this.notifyEvent(103);
  404.                   throw new PrintException(var34);
  405.                }
  406.             }
  407.          } else {
  408.             this.notifyEvent(103);
  409.             throw new PrintJobFlavorException("invalid flavor", var41);
  410.          }
  411.       }
  412.    }
  413.  
  414.    public void printableJob(Printable var1) throws PrintException {
  415.       try {
  416.          synchronized(this) {
  417.             if (this.job != null) {
  418.                throw new PrintException("already printing");
  419.             }
  420.  
  421.             this.job = new WPrinterJob();
  422.          }
  423.  
  424.          PrintService var2 = this.getPrintService();
  425.          this.job.setPrintService(var2);
  426.          if (this.copies == 0) {
  427.             Copies var3 = (Copies)var2.getDefaultAttributeValue(Copies.class);
  428.             this.copies = var3.getValue();
  429.          }
  430.  
  431.          if (this.mediaName == null) {
  432.             Object var12 = var2.getDefaultAttributeValue(Media.class);
  433.             if (var12 instanceof MediaSizeName) {
  434.                this.mediaName = (MediaSizeName)var12;
  435.                this.mediaSize = MediaSize.getMediaSizeForName(this.mediaName);
  436.             }
  437.          }
  438.  
  439.          if (this.orient == null) {
  440.             this.orient = (OrientationRequested)var2.getDefaultAttributeValue(OrientationRequested.class);
  441.          }
  442.  
  443.          this.job.setCopies(this.copies);
  444.          this.job.setJobName(this.jobName);
  445.          PageFormat var13 = new PageFormat();
  446.          if (this.mediaSize != null) {
  447.             Paper var4 = new Paper();
  448.             var4.setSize((double)this.mediaSize.getX(25400) * (double)72.0F, (double)this.mediaSize.getY(25400) * (double)72.0F);
  449.             var4.setImageableArea((double)72.0F, (double)72.0F, var4.getWidth() - (double)144.0F, var4.getHeight() - (double)144.0F);
  450.             var13.setPaper(var4);
  451.          }
  452.  
  453.          if (this.orient == OrientationRequested.REVERSE_LANDSCAPE) {
  454.             var13.setOrientation(2);
  455.          } else if (this.orient == OrientationRequested.LANDSCAPE) {
  456.             var13.setOrientation(0);
  457.          }
  458.  
  459.          this.job.setPrintable(var1, var13);
  460.          this.job.print(this.reqAttrSet);
  461.          this.notifyEvent(106);
  462.       } catch (PrinterException var10) {
  463.          this.notifyEvent(103);
  464.          throw new PrintException(var10);
  465.       } finally {
  466.          this.printReturned = true;
  467.          this.notifyEvent(105);
  468.       }
  469.  
  470.    }
  471.  
  472.    public void pageableJob(Pageable var1) throws PrintException {
  473.       try {
  474.          synchronized(this) {
  475.             if (this.job != null) {
  476.                throw new PrintException("already printing");
  477.             }
  478.  
  479.             this.job = new WPrinterJob();
  480.          }
  481.  
  482.          PrintService var2 = this.getPrintService();
  483.          this.job.setPrintService(var2);
  484.          if (this.copies == 0) {
  485.             Copies var3 = (Copies)var2.getDefaultAttributeValue(Copies.class);
  486.             this.copies = var3.getValue();
  487.          }
  488.  
  489.          this.job.setCopies(this.copies);
  490.          this.job.setJobName(this.jobName);
  491.          this.job.setPageable(var1);
  492.          this.job.print(this.reqAttrSet);
  493.          this.notifyEvent(106);
  494.       } catch (PrinterException var9) {
  495.          this.notifyEvent(103);
  496.          throw new PrintException(var9);
  497.       } finally {
  498.          this.printReturned = true;
  499.          this.notifyEvent(105);
  500.       }
  501.  
  502.    }
  503.  
  504.    private synchronized void initializeAttributeSets(Doc var1, PrintRequestAttributeSet var2) {
  505.       this.reqAttrSet = new HashPrintRequestAttributeSet();
  506.       this.jobAttrSet = new HashPrintJobAttributeSet();
  507.       if (var2 != null) {
  508.          this.reqAttrSet.addAll(var2);
  509.          Attribute[] var3 = var2.toArray();
  510.  
  511.          for(int var4 = 0; var4 < var3.length; ++var4) {
  512.             if (var3[var4] instanceof PrintJobAttribute) {
  513.                this.jobAttrSet.add(var3[var4]);
  514.             }
  515.          }
  516.       }
  517.  
  518.       DocAttributeSet var12 = var1.getAttributes();
  519.       if (var12 != null) {
  520.          Attribute[] var11 = var12.toArray();
  521.  
  522.          for(int var5 = 0; var5 < var11.length; ++var5) {
  523.             if (var11[var5] instanceof PrintRequestAttribute) {
  524.                this.reqAttrSet.add(var11[var5]);
  525.             }
  526.  
  527.             if (var11[var5] instanceof PrintJobAttribute) {
  528.                this.jobAttrSet.add(var11[var5]);
  529.             }
  530.          }
  531.       }
  532.  
  533.       String var13 = "";
  534.  
  535.       try {
  536.          var13 = System.getProperty("user.name");
  537.       } catch (SecurityException var10) {
  538.       }
  539.  
  540.       if (var13 != null && !var13.equals("")) {
  541.          this.jobAttrSet.add(new JobOriginatingUserName(var13, (Locale)null));
  542.       } else {
  543.          RequestingUserName var6 = (RequestingUserName)var2.get(RequestingUserName.class);
  544.          if (var6 != null) {
  545.             this.jobAttrSet.add(new JobOriginatingUserName(var6.getValue(), var6.getLocale()));
  546.          } else {
  547.             this.jobAttrSet.add(new JobOriginatingUserName("", (Locale)null));
  548.          }
  549.       }
  550.  
  551.       if (this.jobAttrSet.get(JobName.class) == null) {
  552.          if (var12 != null && var12.get(DocumentName.class) != null) {
  553.             DocumentName var16 = (DocumentName)var12.get(DocumentName.class);
  554.             JobName var15 = new JobName(var16.getValue(), var16.getLocale());
  555.             this.jobAttrSet.add(var15);
  556.          } else {
  557.             String var7 = "JPS Job:" + var1;
  558.  
  559.             try {
  560.                Object var8 = var1.getPrintData();
  561.                if (var8 instanceof java.net.URL) {
  562.                   var7 = ((java.net.URL)((java.net.URL)var1.getPrintData())).toString();
  563.                }
  564.             } catch (IOException var9) {
  565.             }
  566.  
  567.             JobName var14 = new JobName(var7, (Locale)null);
  568.             this.jobAttrSet.add(var14);
  569.          }
  570.       }
  571.  
  572.       this.jobAttrSet = AttributeSetUtilities.unmodifiableView(this.jobAttrSet);
  573.    }
  574.  
  575.    private void getAttributeValues(DocFlavor var1) throws PrintException {
  576.       if (this.reqAttrSet.get(Fidelity.class) == Fidelity.FIDELITY_TRUE) {
  577.          this.fidelity = true;
  578.       } else {
  579.          this.fidelity = false;
  580.       }
  581.  
  582.       Attribute[] var3 = this.reqAttrSet.toArray();
  583.  
  584.       for(int var4 = 0; var4 < var3.length; ++var4) {
  585.          Attribute var5 = var3[var4];
  586.          Class var2 = var5.getCategory();
  587.          if (this.fidelity) {
  588.             if (!this.service.isAttributeCategorySupported(var2)) {
  589.                this.notifyEvent(103);
  590.                throw new PrintJobAttributeException("unsupported category: " + var2, var2, (Attribute)null);
  591.             }
  592.  
  593.             if (!this.service.isAttributeValueSupported(var5, var1, (AttributeSet)null)) {
  594.                this.notifyEvent(103);
  595.                throw new PrintJobAttributeException("unsupported attribute: " + var5, (Class)null, var5);
  596.             }
  597.          }
  598.  
  599.          if (var2 == Destination.class) {
  600.             URI var6 = ((Destination)var5).getURI();
  601.             if (!"file".equals(var6.getScheme())) {
  602.                this.notifyEvent(103);
  603.                throw new PrintException("Not a file: URI");
  604.             }
  605.  
  606.             try {
  607.                this.mDestination = (new File(var6)).getPath();
  608.             } catch (Exception var10) {
  609.                throw new PrintException(var10);
  610.             }
  611.  
  612.             SecurityManager var7 = System.getSecurityManager();
  613.             if (var7 != null) {
  614.                try {
  615.                   var7.checkWrite(this.mDestination);
  616.                } catch (SecurityException var9) {
  617.                   this.notifyEvent(103);
  618.                   throw new PrintException(var9);
  619.                }
  620.             }
  621.          } else if (var2 == JobName.class) {
  622.             this.jobName = ((JobName)var5).getValue();
  623.          } else if (var2 == Copies.class) {
  624.             this.copies = ((Copies)var5).getValue();
  625.          } else if (var2 == Media.class) {
  626.             if (var5 instanceof MediaSizeName) {
  627.                this.mediaName = (MediaSizeName)var5;
  628.                if (!this.service.isAttributeValueSupported(var5, (DocFlavor)null, (AttributeSet)null)) {
  629.                   this.mediaSize = MediaSize.getMediaSizeForName(this.mediaName);
  630.                }
  631.             }
  632.          } else if (var2 == OrientationRequested.class) {
  633.             this.orient = (OrientationRequested)var5;
  634.          }
  635.       }
  636.  
  637.    }
  638.  
  639.    private native boolean startPrintRawData(String var1, String var2);
  640.  
  641.    private native boolean printRawData(byte[] var1, int var2);
  642.  
  643.    private native boolean endPrintRawData();
  644.  
  645.    public void cancel() throws PrintException {
  646.       synchronized(this) {
  647.          if (!this.printing) {
  648.             throw new PrintException("Job is not yet submitted.");
  649.          } else if (this.job != null && !this.printReturned) {
  650.             this.job.cancel();
  651.             this.notifyEvent(101);
  652.          } else {
  653.             throw new PrintException("Job could not be cancelled.");
  654.          }
  655.       }
  656.    }
  657. }
  658.